Skip to content

Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | practice tdd#1237

Open
mshayriyesaricicek wants to merge 9 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek:Sprint-3-practice-tdd
Open

Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | practice tdd#1237
mshayriyesaricicek wants to merge 9 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek:Sprint-3-practice-tdd

Conversation

@mshayriyesaricicek
Copy link

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

This PR is to practice writing tests before writing functions

@mshayriyesaricicek mshayriyesaricicek added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Mar 10, 2026
@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 13, 2026
@mshayriyesaricicek mshayriyesaricicek added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 14, 2026
Comment on lines +27 to +31
expect(countChar("aaaaa", 'b")).toEqual(5);
expect(countChar("blind", 'a)).toEqual(0);
expect(countChar("blood", 'o")).toEqual(2);
expect(countChar("bbbrf", 'b")).toEqual(3);
expect(countChar("ooooa", 'o")).toEqual(4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off.

function getOrdinalNumber(num) {
return "1st";
// Check if input is a number
if (typeof num !== "number" || isNaN(num)) || !Number.isInteger(num) || !Number.isFinite(num)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ensure num is integer, but some of the checks are redundant.

Can you delete those that are redundant?

throw new Error("Input must be a valid number");
}

const lastnum = num % 10; // checks what last number is
Copy link
Contributor

@cjyuan cjyuan Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The convention is to name variable in camelCase. For examples, lastNum or lastDigit.

Comment on lines +47 to +51
test("should append 'th' if nunber is 11 or does not end in 1, 2 or 3 ", () => {
expect(getOrdinalNumber(20)).toEqual("20th");
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(99)).toEqual("99th");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"should append 'th' if nunber is 11 or does not end in 1, 2 or 3" -- This description does not yet cover all the "remaining numbers". Can you revise it?

Comment on lines +24 to +35
test("should repeat the string count times", () => {
const str = "hello";
const count = 1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hello");
});

// Case: Handle count of 0:
// Given a target string `str` and a `count` equal to 0,
// When the repeatStr function is called with these inputs,
// Then it should return an empty string.
// If the the string is empty then count will be 0
// and an empty string will be returned

test("should repeat the string count times", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests have the same description. When one of them fails, it may take one longer time to figure out which of these tests fails. Can you revise them to make the description distinct?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants